package cn.wlj.origin;

import com.rabbitmq.client.Channel;
import com.rabbitmq.client.Connection;
import com.rabbitmq.client.ConnectionFactory;

import java.io.IOException;
import java.util.concurrent.TimeoutException;

/**
 * @ClassName ConnectUtil
 * @Description TODO 获取连接的工具类
 * @Author WLJ
 * @Date 2024/1/9 20:23
 * @Version 1.0
 */
public class ConnectUtil {

    public static Connection getConnection() {
        //创建connection
        ConnectionFactory connectionFactory = new ConnectionFactory();
        connectionFactory.setHost("localhost");
        try {
            return connectionFactory.newConnection();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (TimeoutException e) {
            e.printStackTrace();
        }
        return null;
    }
}
